Miles Sound System SDK 7.2a

MIDILOG - MIDI File Event Filter

Discussion

The MIDILOG program strips any non-standard headers and trailers from a Standard MIDI file, and optionally translates certain MIDI events in the file.

The ability to translate MIDI events makes MIDILOG a powerful tool when dealing with sequencer programs that do not allow certain events to be embedded in a MIDI file, but which are capable of recording other types of events which may be replaced later with the events originally desired by the musician or programmer.

MIDILOG has the following command-line syntax:


MIDILOG infile outfile [logfile]

where infile refers to the original MIDI file to be translated, outfile specifies the MIDI output file, and logfile specifies an optional ASCII text file containing a list of event translation rules to apply to the infile's MIDI events while copying them to the outfile.

An event translation rule consists of two expressions separated by an '=' sign. Both expressions represent MIDI events. During the MIDI file translation process, MIDILOG compares each event in the infile with each event translation rule's lvalue, or the expression on the left side of its '=' sign. If no match is found, the infile's event is written, unchanged, to the outfile. However, if the event matches one of the logfile's lvalues, the event on the right side of the same event translation rule's '=' sign, called the rvalue, is written to the outfile instead.

Up to 128 event translation rules may appear in each logfile. Each expression used in an event translation rule must take one of the following forms. (Terms in [] brackets may appear zero or more times).

event( [val,] ): Any MIDI event.

meta_event( type, [val,] ): A MIDI meta-event of type /type/, optionally containing zero or more bytes of associated data. For example, meta_event(1, "Test") is identical to event($FF,$01,$04, "Test").

MT32_sysex_event( addr_MSB, addr, addr_LSB, data, [data,]): A type DT1 System Exclusive event capable of addressing Roland MT-32-compatible synthesizers. No nibble masks or wildcards (see below) may be used. For example, MT32_sysex_event($20,$00,$00, "This is a test"), when written to a MIDI file as an rvalue, will cause the string 'This is a test' to appear on the MT-32's front-panel LCD display when the file is performed.

The values used within each expression must conform to the following rules:

$nn: A single hexadecimal byte, which may be 1 or 2 digits in length. The letter 'x' may be used to mask one of the nibbles in the byte, causing that nibble to be disregarded in event comparisons. The value of the last nibble masked in a rule's lvalue is restored to any masked nibbles in the rvalue, which is useful for preserving channel nibbles in replaced MIDI status bytes. Character case is not meaningful. Examples: $4, $69, $Bx.

nnn: A single decimal byte, which may range from 1 to 3 digits in length. Examples: 4, 105, 176.

'...' / "...": A string literal value. Either apostrophes or quotation marks may be used. Examples: 'Test', "Test".

? or $xx: Wildcard decimal byte value. The entire byte is masked (disregarded in event comparisons). The value of the last byte masked in a rule's lvalue is restored to any masked bytes in the rvalue, which is useful for preserving data bytes in replaced MIDI events.

Commas must be used to separate values within expressions. Up to 16 bytes may appear in each rule's lvalue expression, while as many as 128 bytes may appear in each rvalue expression.

All characters appearing on a line after a semicolon (';') are considered to be comments, and are ignored. All characters appearing before an equal sign ('=') are considered to be part of the rule's lvalue expression; all characters appearing after an equal sign are considered to be part of its rvalue expression. For example, the line:


event($Bx,120,0) = meta_event($01, "Test") ;Control Change #120

contains a valid event translation rule which will trap infile events that set Controller 120 in any MIDI channel to a value of 0, replacing them in the outfile with Text meta-events containing the string "Test".

An empty rvalue in a rule (such as event( )) may be used to completely remove events which match the rule's lvalue. When an event is removed in this manner, however, its delta-time prefix is removed as well. This may cause loss of synchronization between tracks. To avoid this problem, it is best to replace the undesired event with an unrecognized Control Change or similar event, rather than simply preventing it from appearing in the outfile.

It is impossible to use MIDILOG's advanced features effectively without a good understanding of MIDI events and the Standard MIDI File specification. However, an in-depth examination of these subjects is beyond the scope of this documentation. To learn more about all aspects of MIDI, refer to a good general-purpose reference such as De Furia and Scacciaferro's MIDI Programmer's Handbook.

Below is a sample logfile for use with MIDILOG.


;
;SYSTEST.LOG
;Sample event translation logfile - turns SEQ.MID into APP.MID
;
;Usage: midilog seq.mid app.mid systest.log
;
event($Bx,118,0) = meta_event($01, "Second measure")
event($Bx,119,1) = meta_event($02, "Copyright (C) 1991")
event($Bx,120,?) = meta_event($7E,?) ;Generic meta
event($Bx,117,?) = event($F0,$43,$12,$00,$07,$F7) ;Generic sysex
event($Bx,116,?) = MT32_sysex_event($10,$00,$01,1,7,7) ;MT-32 reverb

Next Topic (MIDIREC- Standard MIDI File Recorder)

Previous Topic (CLAD - Creative Labs and Ad Lib (TM) Converter)


Group: Miles Sound System Tools Reference

For technical support, e-mail Miles3@radgametools.com
© Copyright 1991-2007 RAD Game Tools, Inc. All Rights Reserved.